<template>
    <div class="cmitem">
        <el-form-item prop="programtype" label="节目类型">
            <el-select v-model="localFormData.programtype" placeholder="请选择节目类型" >
                <el-option
                v-for="item in programTypeData"
                :key="item.value"
                :label="item.text"
                :value="item.value">
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="出品时间" prop="productiontime">
            <el-date-picker v-model="localFormData.productiontime" value-format='YYYY-MM-DD' type="date" placeholder="请选择出品时间">
            </el-date-picker>
        </el-form-item>
        <el-form-item prop="productioncompany" label="出品公司">
            <el-select
                v-model="localFormData.productioncompany"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择出品公司"
            >
                <!--<el-option
                v-for="item in attrInfo.optionsData"
                :key="item"
                :label="item"
                :value="item"
                >
                </el-option>-->
            </el-select>
        </el-form-item>
        <el-form-item label="时长" prop="duration">
            <el-input v-model.number="localFormData.duration" placeholder="请输入时长"></el-input>
        </el-form-item>
        <el-form-item label="上映年份" prop="releaseyear">
            <el-date-picker v-model="localFormData.releaseyear" type="year" value-format='YYYY' placeholder="请选择上映年份">
            </el-date-picker>
        </el-form-item>
        <el-form-item label="上映日期" prop="releasedate">
            <el-date-picker v-model="localFormData.releasedate" type="date" value-format='YYYY-MM-DD' placeholder="请选择上映日期">
            </el-date-picker>
        </el-form-item>
        <el-form-item label="官方网站" prop="website">
            <el-input v-model="localFormData.website" placeholder="请输入官方网站"></el-input>
        </el-form-item>
        <el-form-item label="总集数" prop="totalnum">
            <el-input v-model.number="localFormData.totalnum" placeholder="请输入总集数"></el-input>
        </el-form-item>
        <el-form-item label="更新集数" prop="updatenum">
            <el-input v-model="localFormData.updatenum" placeholder="请输入更新集数"></el-input>
        </el-form-item>
        <el-form-item prop="language" label="语言">
            <el-select
                v-model="localFormData.language"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择语言"
            >
                <el-option
                v-for="item in languageData"
                :key="item.id"
                :label="item.name"
                :value="item.name"
                >
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item prop="area" label="地区">
            <el-select
                v-model="localFormData.area"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择地区"
            >
                <el-option
                v-for="item in areaData"
                :key="item.id"
                :label="item.name"
                :value="item.name"
                >
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item prop="isfinish" label="是否完结">
            <el-radio key="1" :label="1" :value="1" v-model="localFormData.isfinish">是</el-radio>
            <el-radio key="0" :label="0" :value="1" v-model="localFormData.isfinish">否</el-radio>
        </el-form-item>
        <el-form-item prop="director" label="导演">
            <el-select
                v-model="localFormData.director"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择导演"
            >
                <el-option
                v-for="item in personData"
                :key="item.id"
                :label="item.name"
                :value="item.name"
                >
                </el-option>
            </el-select>
        </el-form-item>
        
        <el-form-item prop="screenwriter" label="编剧">
            <el-select
                v-model="localFormData.screenwriter"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择编剧"
            >
                <el-option
                v-for="item in personData"
                :key="item.id"
                :label="item.name"
                :value="item.name"
                >
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item v-if="localFormData.mediaid == undefined" prop="hasseries" label="是否多集">
            <el-radio key="1" :label="1" :value="1" v-model="localFormData.hasseries">是</el-radio>
            <el-radio key="0" :label="0" :value="1" v-model="localFormData.hasseries">否</el-radio>
        </el-form-item>
        <el-form-item v-else prop="hasseries" label="是否多集">
            <el-radio key="1" :label="1" :value="1" v-model="localFormData.hasseries" :disabled="true">是</el-radio>
            <el-radio key="0" :label="0" :value="1" v-model="localFormData.hasseries" :disabled="true">否</el-radio>
        </el-form-item>
        <el-form-item prop="star" label="主演" class="txtareabox">
            <el-select
                v-model="localFormData.star"
                multiple
                filterable
                allow-create
                default-first-option
                placeholder="请选择主演"
            >
                <el-option
                v-for="item in personData"
                :key="item.id"
                :label="item.name"
                :value="item.name"
                >
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="评分" prop="score">
            <el-input v-model.number="localFormData.score" placeholder="请输入评分"></el-input>
        </el-form-item>
        <el-form-item label="IMDB编码" prop="imdbcode">
            <el-input v-model="localFormData.imdbcode" placeholder="请输入IMDB编码"></el-input>
        </el-form-item>
    </div>
</template>

<script>
    import {toRef, ref} from 'vue'
    import { getPersons, getAreas, getLanguages } from '@/api/media/constant'
    import programTypeMixin from "@/mixins/programTypeMixin";
    export default {
        name: "",
        components: {},
        props: {
            formData: {
                type: Object
            },
        },
        setup(props) {
            const localFormData = toRef(props, 'formData')
            console.log(localFormData)
            const {programTypeData} = programTypeMixin()

            const personData = ref([])
            const areaData = ref([])
            const languageData = ref([])
            getPersons({pagesize:1000}).then(response => {
                if( response.errcode == 0 ){
                    personData.value = response.data.list
                }else{
                    console.log(response)
                }
            })
            getAreas({pagesize:1000}).then(response => {
                if( response.errcode == 0 ){
                    areaData.value = response.data.list
                }else{
                    console.log(response)
                }
            })
            getLanguages({pagesize:1000}).then(response => {
                if( response.errcode == 0 ){
                    languageData.value = response.data.list
                }else{
                    console.log(response)
                }
            })

            return {
                localFormData,
                programTypeData,
                personData,
                areaData,
                languageData
            }
        }
    }
</script>

<style scoped  lang="scss">

</style>